function createyeargridview(option) {
    if ("undefined" == typeof option.search) {
        Ext.MessageBox.show({
            title : "系统提示",
            msg : "search is null",
            icon : Ext.MessageBox.INFO,
            buttons : Ext.Msg.OK
        });
        return;
    }

    if ("undefined" == typeof option.grid) {
        Ext.MessageBox.show({
            title : "系统提示",
            msg : "grid is null",
            icon : Ext.MessageBox.INFO,
            buttons : Ext.Msg.OK
        });
        return;
    }

    if ("undefined" == typeof option.topbar) {
        Ext.MessageBox.show({
            title : "系统提示",
            msg : "grid is null",
            icon : Ext.MessageBox.INFO,
            buttons : Ext.Msg.OK
        });
        return;
    }

    if ("undefined" == typeof option.tree) {
        Ext.MessageBox.show({
            title : "系统提示",
            msg : "grid is null",
            icon : Ext.MessageBox.INFO,
            buttons : Ext.Msg.OK
        });
        return;
    }

    option.search.id = option.search.id || "";
    option.search.items = option.search.items || [];
    option.grid.fields = option.grid.fields || [];
    option.grid.columns = option.grid.columns || [];
    option.grid.id = option.grid.id || "";
    option.grid.title = option.grid.title || "";
    option.grid.listUrl = option.grid.listUrl || "";
    option.grid.removeUrl = option.grid.removeUrl || "";
    if ("undefined" == typeof option.grid.rowActions)
        option.grid.rowActions = true
    option.tree.id = option.tree.id || "";
    option.tree.treeUrl = option.tree.treeUrl || "";
    option.topbar.inputFormName = option.topbar.inputFormName || "";

    if ("undefined" == typeof option.topbar.topbarAdd)
        if ("undefined" == typeof option.topbar.topbarAdd.hidden)
            option.topbar.topbarAdd.hidden = false;
    if ("undefined" == typeof option.topbar.topbarDel)
        if ("undefined" == typeof option.topbar.topbarDel.hidden)
            option.topbar.topbarDel.hidden = false;

    var yearGridColumnCount = [];

    this.reset = function(viewPanel) {
        var searchForm = viewPanel.yearGridSearchPanel;
        searchForm.getForm().reset();
    };

    this.search = function(viewPanel) {
        var searchForm = viewPanel.yearGridSearchPanel;
        var gridPanel = viewPanel.yearGridPanel;
        if (searchForm.getForm().isValid()) {
            $search({
                searchPanel : searchForm,
                gridPanel : gridPanel
            });
        }
    }

    this.onRowActions = function(c, a, d, e, b) {
        switch (d) {
        case "btn-edit":
            this.editById.call(this, a);
            break;
        case "btn-delete": 
            this.removeById.call(this, option.grid.key==null?a.data.id:a.data[option.grid.key]);
            break;
        default:
            break;
        }
    };

    this.editById = function(a) {
        var inputName = option.topbar.inputFormName;
        var cfg = {
            id : a.data.id,
            operation : Constant.Operation.EDIT,
            inputFormName : option.topbar.inputFormName,
            addYearGridPanel : this.yearGridPanel.getId()
        };
        var str = "new " + inputName + "(" + JSON.stringify(cfg) + ")";
        eval(str).show();
    };

    this.removeById = function(a) {
        Ext.Msg.confirm("操作提示", "你真的要删除所选数据吗？", function(b) {
            if (b == "yes") {
                Ext.Ajax.request({
                    url : option.grid.removeUrl,
                    params : {
                        ids : a
                    },
                    scope : this,
                    method : "post",
                    waitMsg : "数据正在提交，请稍后...",
                    success : function(c, d) {
                        Ext.ux.Toast.msg("操作提示", "数据删除成功！");
                        this.yearGridPanel.getStore().reload();
                    },
                    failure : function() {
                        Ext.ux.Toast.msg("操作提示", "对不起，数据提交失败！");
                    }
                });
            }
        }, this);
    };

    this.removeByIds = function(object) {
        var a = object.yearGridPanel.getSelectionModel().getSelections();
        if (a.length > 0) {
            var c = new Array();
            for (var b = 0; b < a.length; b++) {
                c.push(a[b].data.id);
            }
            object.removeById(c);
        } else {
            Ext.ux.Toast.msg("操作提示", "对不起，请选择要删除的员工信息！");
        }
    };

    this.clickNode = function(f) {
        if (f) {
            this.yearGridTreePanel.getSelectionModel().clearSelections();
            this.yearGridTreePanel.getSelectionModel().select(f);
        }
        var c = this.yearGridPanel.getStore();
        var d = {
            start : 0,
            limit : 25
        };
        c.reload({
            params : d
        });
    };

    /*
     * //动态添加列
     * yearGridPanel.reconfigure(yearGridPanel.getStore(),option.grid.columns); }
     */
    if (option.grid.columns.length > 0) {

        for (var i = 0; i < option.grid.columns.length; i++) {
            yearGridColumnCount.push(option.grid.columns[i]);
        }
        var rowActions = new Ext.ux.grid.RowActions({
            header : "管理",
            width : 60,
            actions : [ {
                iconCls : "btn-delete",
                qtip : "删除",
                style : "margin : 0 3px 0 3px"
            }, {
                iconCls : "btn-edit",
                qtip : "编辑",
                style : "margin : 0 3px 0 3px"
            } ],
            listeners : {
                scope : this,
                "action" : this.onRowActions
            }
        });

        if (option.grid.rowActions == true) {
            yearGridColumnCount.push(rowActions);
        }
    }

    this.yearGridSearchPanel = new Ext.FormPanel({
        id : option.search.id,
        region : "north",
        layout : "form",
        border : false,
        height : 40,
        frame : false,
        layoutConfig : {
            padding : "5px",
            align : "middle"
        },
        items : [ {
            fieldLabel : "请输入搜索条件",
            layout : "column",
            xtype : "container",
            style : "margin-top:8px;",
            border : false,
            defaults : {
                xtype : "label",
                height : 25,
                border : false
            },
            layoutConfig : {
                align : "middle"
            },
            items : [ option.search.items, {
                style : "margin-left:5px;",
                xtype : "button",
                text : "搜索",
                iconCls : "search",
                handler : this.search.createCallback(this)
            }, {
                xtype : "button",
                text : "清空",
                iconCls : "reset",
                handler : this.reset.createCallback(this)
            } ]
        } ]
    });

    this.yearGridTreePanel = new Ext.tree.TreePanel({
        id : option.tree.id,
        region : "west",
        border : false,
        width : 200,
        scope : this,
        allowCheckbox : false,
        collapsible : true,
        autoScroll : true,
        split : true,
        title : "年份列表",
        tbar : new Ext.Toolbar({
            defaultType : "button",
            items : [ {
                text : "刷新",
                iconCls : "btn-refresh",
                scope : this,
                handler : function() {
                    this.yearGridTreePanel.root.reload();
                }
            }, {
                text : "展开",
                scope : this,
                iconCls : "btn-expand",
                handler : function() {
                    this.yearGridTreePanel.expandAll();
                }
            }, {
                text : "收起",
                scope : this,
                iconCls : "btn-collapse",
                handler : function() {
                    this.yearGridTreePanel.collapseAll();
                }
            } ]
        }),
        loader : new Ext.tree.TreeLoader({
            url : option.tree.treeUrl
        }),
        root : new Ext.tree.AsyncTreeNode({
            expanded : true
        }),
        rootVisible : false,
        listeners : {
            scope : this,
            "click" : this.clickNode,
            "load" : function(a) {
                this.yearGridTreePanel.expandAll();
                if (a.childNodes.length == 1) {
                    var array = [];
                    array = a.childNodes;
                    for (var i = 0; i < array.length; i++) {
                        /*
                         * 默认选中当前年份 var date=new Date; var
                         * dateYear=date.getFullYear();
                         * if(array[i].id==dateYear){
                         * yearGridTreePanel.getSelectionModel().select(array[i]);
                         * var c = yearGridPanel.getStore(); var d = { start :
                         * 0, limit : 25 }; c.reload({ params : d }); }
                         */
                        // 默认选中全部
                        this.yearGridTreePanel.getSelectionModel().select(array[i]);
                    }
                }

            }
        }
    });

    /*
     * var record = yearGridTreePanel.getStore().getNodeById('2016');
     * yearGridTreePanel.getSelectionModel().select('')
     */
    var yearGridTopbarItems = [];
    yearGridTopbarItems.push({
        text : "添加",
        scope : this,
        hidden : option.topbar.topbarAdd.hidden,
        iconCls : "add-user",
        handler : function() {
            var f = this.yearGridTreePanel.getSelectionModel().getSelectedNode();
            if (f != null && f.id > 0) {
                var inputFormName = option.topbar.inputFormName;
                var cfg = {
                    operation : Constant.Operation.ADD,
                    years : f.id,
                    inputFormName : option.topbar.inputFormName,
                    addYearGridPanel : this.yearGridPanel.getId()
                }
                var str = "new " + inputFormName + "(" + JSON.stringify(cfg) + ")";
                eval(str).show();
            } else {
                Ext.ux.Toast.msg("提示", "请选择年份列表下年份信息！");
            }
        }
    });
    if ("undefined" != typeof option.topbar) {
        if ("undefined" != typeof option.topbar.topbarAdd) {
            if (option.topbar.topbarAdd.hidden == true || option.topbar.topbarDel.hidden == true) {
                yearGridTopbarItems.push(" ");
            } else {
                yearGridTopbarItems.push("-");
            }
        }
    }

    yearGridTopbarItems.push({
        text : "删除",
        hidden : option.topbar.topbarDel.hidden,
        iconCls : "btn-delete",
        scope : this,
        handler : this.removeByIds.createCallback(this)
    });

    yearGridTopbar = new Ext.Toolbar({
        defaultType : "button",
        items : yearGridTopbarItems
    });

    this.yearGridPanel = new HT.GridPanel({
        id : option.grid.id,
        title : option.grid.title,
        region : "center",
        tbar : yearGridTopbar,
        rowActions : option.grid.rowActions,
        url : option.grid.listUrl,
        trackMouseOver : true,
        disableSelection : false,
        loadMask : true,
        viewConfig : {
            forceFit : true,
            enableRowBody : false,
            showPreview : false
        },
        fields : option.grid.fields,
        columns : yearGridColumnCount
    });

    this.yearGridPanel.addListener("rowdblclick", function(grid, rowIndex, columnIndex, event) {
        //by gt 将原来的foreach循环打开选中记录（会导致打开窗口过多卡死现象），改为只打开一个  
        var record = grid.getStore().getAt(rowIndex);
        var inputName = option.topbar.inputFormName;
        var cfg = {
            id : record.data.id,
            isShow : true,
            operation : Constant.Operation.VIEW,
            years : record.data.years,
            inputFormName : option.topbar.inputFormName
        };
        var str = "new " + inputName + "(" + JSON.stringify(cfg) + ")";
        eval(str).show();
    });

    // 载入前带查询条件的翻页
    this.yearGridPanel.getStore().on('beforeload', function(store, options) {
        var tree = this.yearGridTreePanel.getSelectionModel().getSelectedNode();
        for (var i = 0; i < option.search.items.length; i++) {
            if (option.search.items[i].name != undefined) {
                var name = option.search.items[i].name.split("_")[1];
                var searchName = option.search.items[i].name;
                var new_params = {
                    searchName : name
                };
                if (tree != null && tree.id > 1) {
                    new_params["Q_years_S_EQ"] = tree.id;
                }
                Ext.apply(options.params, new_params);
            }
        }
    }, this);
    /*
     * var yearGridComponents=[];
     * 
     * yearGridComponents.push(yearGridPanel);
     * yearGridComponents.push(yearGridSearchPanel);
     * yearGridComponents.push(yearGridTreePanel);
     * 
     * return yearGridComponents;
     */

}